<?php require_once('../Connections/webtintuc.php'); ?>
<?php require_once('../Connections/webtintuc.php'); ?>
<?php
// Load the common classes
require_once('../includes/common/KT_common.php');

// Load the common classes
require_once('../includes/common/KT_common.php');

// Load the tNG classes
require_once('../includes/tng/tNG.inc.php');

// Load the required classes
require_once('../includes/tfi/TFI.php');
require_once('../includes/tso/TSO.php');
require_once('../includes/nav/NAV.php');

// Load the required classes
require_once('../includes/tfi/TFI.php');
require_once('../includes/tso/TSO.php');
require_once('../includes/nav/NAV.php');

// Make unified connection variable
$conn_webtintuc = new KT_connection($webtintuc, $database_webtintuc);

// Make unified connection variable
$conn_webtintuc = new KT_connection($webtintuc, $database_webtintuc);

//Start Restrict Access To Page
$restrict = new tNG_RestrictAccess($conn_webtintuc, "../");
//Grand Levels: Level
$restrict->addLevel("1");
$restrict->Execute();
//End Restrict Access To Page

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "") 
{
  $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch ($theType) {
    case "text":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;    
    case "long":
    case "int":
      $theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case "double":
      $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
      break;
    case "date":
      $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
      break;
    case "defined":
      $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
      break;
  }
  return $theValue;
}
}

// Filter
$tfi_listusers1 = new TFI_TableFilter($conn_webtintuc, "tfi_listusers1");
$tfi_listusers1->addColumn("users.HoTen", "STRING_TYPE", "HoTen", "%");
$tfi_listusers1->addColumn("users.Username", "STRING_TYPE", "Username", "%");
$tfi_listusers1->addColumn("users.Password", "STRING_TYPE", "Password", "%");
$tfi_listusers1->addColumn("users.DiaChi", "STRING_TYPE", "DiaChi", "%");
$tfi_listusers1->addColumn("users.Dienthoai", "STRING_TYPE", "Dienthoai", "%");
$tfi_listusers1->addColumn("users.Email", "STRING_TYPE", "Email", "%");
$tfi_listusers1->addColumn("users.NgayDangKy", "DATE_TYPE", "NgayDangKy", "=");
$tfi_listusers1->addColumn("users.LoginNumber", "NUMERIC_TYPE", "LoginNumber", "=");
$tfi_listusers1->addColumn("users.DisableDate", "DATE_TYPE", "DisableDate", "=");
$tfi_listusers1->Execute();

// Sorter
$tso_listusers1 = new TSO_TableSorter("rsusers1", "tso_listusers1");
$tso_listusers1->addColumn("users.HoTen");
$tso_listusers1->addColumn("users.Username");
$tso_listusers1->addColumn("users.Password");
$tso_listusers1->addColumn("users.DiaChi");
$tso_listusers1->addColumn("users.Dienthoai");
$tso_listusers1->addColumn("users.Email");
$tso_listusers1->addColumn("users.NgayDangKy");
$tso_listusers1->addColumn("users.LoginNumber");
$tso_listusers1->addColumn("users.DisableDate");
$tso_listusers1->setDefault("users.HoTen");
$tso_listusers1->Execute();

// Navigation
$nav_listusers1 = new NAV_Regular("nav_listusers1", "rsusers1", "../", $_SERVER['PHP_SELF'], 10);

// Filter
$tfi_listusers2 = new TFI_TableFilter($conn_webtintuc, "tfi_listusers2");
$tfi_listusers2->addColumn("users.HoTen", "STRING_TYPE", "HoTen", "%");
$tfi_listusers2->addColumn("users.Username", "STRING_TYPE", "Username", "%");
$tfi_listusers2->addColumn("users.Password", "STRING_TYPE", "Password", "%");
$tfi_listusers2->addColumn("users.Email", "STRING_TYPE", "Email", "%");
$tfi_listusers2->Execute();

// Sorter
$tso_listusers2 = new TSO_TableSorter("rsusers2", "tso_listusers2");
$tso_listusers2->addColumn("users.HoTen");
$tso_listusers2->addColumn("users.Username");
$tso_listusers2->addColumn("users.Password");
$tso_listusers2->addColumn("users.Email");
$tso_listusers2->setDefault("users.HoTen");
$tso_listusers2->Execute();

// Navigation
$nav_listusers2 = new NAV_Regular("nav_listusers2", "rsusers2", "../", $_SERVER['PHP_SELF'], 10);

//NeXTenesio3 Special List Recordset
$maxRows_rsusers1 = $_SESSION['max_rows_nav_listusers1'];
$pageNum_rsusers1 = 0;
if (isset($_GET['pageNum_rsusers1'])) {
  $pageNum_rsusers1 = $_GET['pageNum_rsusers1'];
}
$startRow_rsusers1 = $pageNum_rsusers1 * $maxRows_rsusers1;

// Defining List Recordset variable
$NXTFilter_rsusers1 = "1=1";
if (isset($_SESSION['filter_tfi_listusers1'])) {
  $NXTFilter_rsusers1 = $_SESSION['filter_tfi_listusers1'];
}
// Defining List Recordset variable
$NXTSort_rsusers1 = "users.HoTen";
if (isset($_SESSION['sorter_tso_listusers1'])) {
  $NXTSort_rsusers1 = $_SESSION['sorter_tso_listusers1'];
}
mysql_select_db($database_webtintuc, $webtintuc);

$query_rsusers1 = "SELECT users.HoTen, users.Username, users.Password, users.DiaChi, users.Dienthoai, users.Email, users.NgayDangKy, users.LoginNumber, users.DisableDate, users.idUser FROM users WHERE {$NXTFilter_rsusers1} ORDER BY {$NXTSort_rsusers1}";
$query_limit_rsusers1 = sprintf("%s LIMIT %d, %d", $query_rsusers1, $startRow_rsusers1, $maxRows_rsusers1);
$rsusers1 = mysql_query($query_limit_rsusers1, $webtintuc) or die(mysql_error());
$row_rsusers1 = mysql_fetch_assoc($rsusers1);

if (isset($_GET['totalRows_rsusers1'])) {
  $totalRows_rsusers1 = $_GET['totalRows_rsusers1'];
} else {
  $all_rsusers1 = mysql_query($query_rsusers1);
  $totalRows_rsusers1 = mysql_num_rows($all_rsusers1);
}
$totalPages_rsusers1 = ceil($totalRows_rsusers1/$maxRows_rsusers1)-1;
//End NeXTenesio3 Special List Recordset

//NeXTenesio3 Special List Recordset
$maxRows_rsusers2 = $_SESSION['max_rows_nav_listusers2'];
$pageNum_rsusers2 = 0;
if (isset($_GET['pageNum_rsusers2'])) {
  $pageNum_rsusers2 = $_GET['pageNum_rsusers2'];
}
$startRow_rsusers2 = $pageNum_rsusers2 * $maxRows_rsusers2;

// Defining List Recordset variable
$NXTFilter_rsusers2 = "1=1";
if (isset($_SESSION['filter_tfi_listusers2'])) {
  $NXTFilter_rsusers2 = $_SESSION['filter_tfi_listusers2'];
}
// Defining List Recordset variable
$NXTSort_rsusers2 = "users.HoTen";
if (isset($_SESSION['sorter_tso_listusers2'])) {
  $NXTSort_rsusers2 = $_SESSION['sorter_tso_listusers2'];
}
mysql_select_db($database_webtintuc, $webtintuc);

$query_rsusers2 = "SELECT users.HoTen, users.Username, users.Password, users.Email, users.idUser FROM users WHERE {$NXTFilter_rsusers2} ORDER BY {$NXTSort_rsusers2}";
$query_limit_rsusers2 = sprintf("%s LIMIT %d, %d", $query_rsusers2, $startRow_rsusers2, $maxRows_rsusers2);
$rsusers2 = mysql_query($query_limit_rsusers2, $webtintuc) or die(mysql_error());
$row_rsusers2 = mysql_fetch_assoc($rsusers2);

if (isset($_GET['totalRows_rsusers2'])) {
  $totalRows_rsusers2 = $_GET['totalRows_rsusers2'];
} else {
  $all_rsusers2 = mysql_query($query_rsusers2);
  $totalRows_rsusers2 = mysql_num_rows($all_rsusers2);
}
$totalPages_rsusers2 = ceil($totalRows_rsusers2/$maxRows_rsusers2)-1;
//End NeXTenesio3 Special List Recordset

$nav_listusers1->checkBoundries();

$nav_listusers2->checkBoundries();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Untitled Document</title>
<link href="main.css" rel="stylesheet" type="text/css" />
<link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="../includes/common/js/base.js" type="text/javascript"></script>
<script src="../includes/common/js/utility.js" type="text/javascript"></script>
<script src="../includes/skins/style.js" type="text/javascript"></script>
<script src="../includes/nxt/scripts/list.js" type="text/javascript"></script>
<script src="../includes/nxt/scripts/list.js.php" type="text/javascript"></script>
<script type="text/javascript">
$NXT_LIST_SETTINGS = {
  duplicate_buttons: true,
  duplicate_navigation: true,
  row_effects: true,
  show_as_buttons: true,
  record_counter: true
}
</script>
<style type="text/css">
  /* Dynamic List row settings */
  .KT_col_HoTen {width:140px; overflow:hidden;}
  .KT_col_Username {width:140px; overflow:hidden;}
  .KT_col_Password {width:140px; overflow:hidden;}
  .KT_col_DiaChi {width:140px; overflow:hidden;}
  .KT_col_Dienthoai {width:140px; overflow:hidden;}
  .KT_col_Email {width:140px; overflow:hidden;}
  .KT_col_NgayDangKy {width:140px; overflow:hidden;}
  .KT_col_LoginNumber {width:140px; overflow:hidden;}
  .KT_col_DisableDate {width:140px; overflow:hidden;}
</style>
<link href="../includes/skins/mxkollection3.css" rel="stylesheet" type="text/css" media="all" />
<script src="../includes/common/js/base.js" type="text/javascript"></script>
<script src="../includes/common/js/utility.js" type="text/javascript"></script>
<script src="../includes/skins/style.js" type="text/javascript"></script>
<script src="../includes/nxt/scripts/list.js" type="text/javascript"></script>
<script src="../includes/nxt/scripts/list.js.php" type="text/javascript"></script>
<script type="text/javascript">
$NXT_LIST_SETTINGS = {
  duplicate_buttons: true,
  duplicate_navigation: true,
  row_effects: true,
  show_as_buttons: true,
  record_counter: true
}
</script>
<style type="text/css">
  /* Dynamic List row settings */
  .KT_col_HoTen {width:140px; overflow:hidden;}
  .KT_col_Username {width:140px; overflow:hidden;}
  .KT_col_Password {width:140px; overflow:hidden;}
  .KT_col_Email {width:140px; overflow:hidden;}
</style>
</head>

<body>
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr>
    <td id="banner" colspan="2">TIN TỨC ONLINE. TRANG QUẢN TRỊ</td>
  </tr>
  <tr>
    <td width="150" valign="top" id="left"><table id="menu" width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td><a href="index.php">Trang chủ</a></td>
      </tr>
      <tr>
        <td><a href="listTheLoai.php"> thể loại</a></td>
      </tr>
      <tr>
        <td><a href="listLoaiTin.php"> loại tin</a></td>
      </tr>
      <tr>
        <td><a href="listUsers.php">Users</a></td>
      </tr>
      <tr>
        <td><a href="listTin.php"> Tin</a></td>
      </tr>
      <tr>
        <td><a href="../index.php"> thoát</a></td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
      <tr>
        <td>&nbsp;</td>
      </tr>
    </table></td>
    <td valign="top" id="right">&nbsp;
      <div class="KT_tng" id="listusers2">
        <h1> Users
          <?php
  $nav_listusers2->Prepare();
  require("../includes/nav/NAV_Text_Statistics.inc.php");
?>
        </h1>
        <div class="KT_tnglist">
          <form action="<?php echo KT_escapeAttribute(KT_getFullUri()); ?>" method="post" id="form1">
            <div class="KT_options"> <a href="<?php echo $nav_listusers2->getShowAllLink(); ?>"><?php echo NXT_getResource("Show"); ?>
              <?php 
  // Show IF Conditional region1
  if (@$_GET['show_all_nav_listusers2'] == 1) {
?>
                <?php echo $_SESSION['default_max_rows_nav_listusers2']; ?>
                <?php 
  // else Conditional region1
  } else { ?>
                <?php echo NXT_getResource("all"); ?>
                <?php } 
  // endif Conditional region1
?>
                  <?php echo NXT_getResource("records"); ?></a> &nbsp;
              &nbsp;
                <?php 
  // Show IF Conditional region2
  if (@$_SESSION['has_filter_tfi_listusers2'] == 1) {
?>
                  <a href="<?php echo $tfi_listusers2->getResetFilterLink(); ?>"><?php echo NXT_getResource("Reset filter"); ?></a>
                  <?php 
  // else Conditional region2
  } else { ?>
                  <a href="<?php echo $tfi_listusers2->getShowFilterLink(); ?>"><?php echo NXT_getResource("Show filter"); ?></a>
                  <?php } 
  // endif Conditional region2
?>
            </div>
            <table cellpadding="2" cellspacing="0" class="KT_tngtable">
              <thead>
                <tr class="KT_row_order">
                  <th> <input type="checkbox" name="KT_selAll" id="KT_selAll"/>
                  </th>
                  <th id="HoTen" class="KT_sorter KT_col_HoTen <?php echo $tso_listusers2->getSortIcon('users.HoTen'); ?>"> <a href="<?php echo $tso_listusers2->getSortLink('users.HoTen'); ?>">HoTen</a> </th>
                  <th id="Username" class="KT_sorter KT_col_Username <?php echo $tso_listusers2->getSortIcon('users.Username'); ?>"> <a href="<?php echo $tso_listusers2->getSortLink('users.Username'); ?>">Username</a> </th>
                  <th id="Password" class="KT_sorter KT_col_Password <?php echo $tso_listusers2->getSortIcon('users.Password'); ?>"> <a href="<?php echo $tso_listusers2->getSortLink('users.Password'); ?>">Password</a> </th>
                  <th id="Email" class="KT_sorter KT_col_Email <?php echo $tso_listusers2->getSortIcon('users.Email'); ?>"> <a href="<?php echo $tso_listusers2->getSortLink('users.Email'); ?>">Email</a> </th>
                  <th>&nbsp;</th>
                </tr>
                <?php 
  // Show IF Conditional region3
  if (@$_SESSION['has_filter_tfi_listusers2'] == 1) {
?>
                  <tr class="KT_row_filter">
                    <td>&nbsp;</td>
                    <td><input type="text" name="tfi_listusers2_HoTen" id="tfi_listusers2_HoTen" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listusers2_HoTen']); ?>" size="20" maxlength="100" /></td>
                    <td><input type="text" name="tfi_listusers2_Username" id="tfi_listusers2_Username" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listusers2_Username']); ?>" size="20" maxlength="50" /></td>
                    <td><input type="text" name="tfi_listusers2_Password" id="tfi_listusers2_Password" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listusers2_Password']); ?>" size="20" maxlength="50" /></td>
                    <td><input type="text" name="tfi_listusers2_Email" id="tfi_listusers2_Email" value="<?php echo KT_escapeAttribute(@$_SESSION['tfi_listusers2_Email']); ?>" size="20" maxlength="255" /></td>
                    <td><input type="submit" name="tfi_listusers2" value="<?php echo NXT_getResource("Filter"); ?>" /></td>
                  </tr>
                  <?php } 
  // endif Conditional region3
?>
              </thead>
              <tbody>
                <?php if ($totalRows_rsusers2 == 0) { // Show if recordset empty ?>
                  <tr>
                    <td colspan="6"><?php echo NXT_getResource("The table is empty or the filter you've selected is too restrictive."); ?></td>
                  </tr>
                  <?php } // Show if recordset empty ?>
                <?php if ($totalRows_rsusers2 > 0) { // Show if recordset not empty ?>
                  <?php do { ?>
                    <tr class="<?php echo @$cnt1++%2==0 ? "" : "KT_even"; ?>">
                      <td><input type="checkbox" name="kt_pk_users" class="id_checkbox" value="<?php echo $row_rsusers2['idUser']; ?>" />
                          <input type="hidden" name="idUser" class="id_field" value="<?php echo $row_rsusers2['idUser']; ?>" />
                      </td>
                      <td><div class="KT_col_HoTen"><?php echo KT_FormatForList($row_rsusers2['HoTen'], 20); ?></div></td>
                      <td><div class="KT_col_Username"><?php echo KT_FormatForList($row_rsusers2['Username'], 20); ?></div></td>
                      <td><div class="KT_col_Password"><?php echo KT_FormatForList($row_rsusers2['Password'], 20); ?></div></td>
                      <td><div class="KT_col_Email"><?php echo KT_FormatForList($row_rsusers2['Email'], 20); ?></div></td>
                      <td><a class="KT_edit_link" href="formUsers.php?idUser=<?php echo $row_rsusers2['idUser']; ?>&amp;KT_back=1"><?php echo NXT_getResource("edit_one"); ?></a> <a class="KT_delete_link" href="#delete"><?php echo NXT_getResource("delete_one"); ?></a> </td>
                    </tr>
                    <?php } while ($row_rsusers2 = mysql_fetch_assoc($rsusers2)); ?>
                  <?php } // Show if recordset not empty ?>
              </tbody>
            </table>
            <div class="KT_bottomnav">
              <div>
                <?php
            $nav_listusers2->Prepare();
            require("../includes/nav/NAV_Text_Navigation.inc.php");
          ?>
              </div>
            </div>
            <div class="KT_bottombuttons">
              <div class="KT_operations"> <a class="KT_edit_op_link" href="#" onclick="nxt_list_edit_link_form(this); return false;"><?php echo NXT_getResource("edit_all"); ?></a> <a class="KT_delete_op_link" href="#" onclick="nxt_list_delete_link_form(this); return false;"><?php echo NXT_getResource("delete_all"); ?></a> </div>
<span>&nbsp;</span>
              <select name="no_new" id="no_new">
                <option value="1">1</option>
                <option value="3">3</option>
                <option value="6">6</option>
              </select>
              <a class="KT_additem_op_link" href="formUsers.php?KT_back=1" onclick="return nxt_list_additem(this)"><?php echo NXT_getResource("add new"); ?></a> </div>
          </form>
        </div>
        <br class="clearfixplain" />
      </div>
      <p>&nbsp;</p>
    <p>&nbsp;</p></td>
  </tr>
</table>
</body>
</html>
<?php
mysql_free_result($rsusers1);

mysql_free_result($rsusers2);
?>
